<template>
  
  <el-button type="primary" @click="handleLogin">登录</el-button>
  <el-button type="success" @click="handleUserList">用户列表</el-button>
    
</template>

<script  setup>

import requestUtils from '@/util/request'


const handleLogin = async() => {
  let result=await requestUtils.get('user/jwt_test')
  console.log(result)
  let data=result.data
  if (data.code==200){
    const token=data.token
    console.log('登录成功,token为：'+token)
    window.sessionStorage.setItem('token', token)
}else{
    console.log('登录失败')
  }
}

const handleUserList = async() => {
  let result=await requestUtils.get('user/test')
  let data=result.data
  if (data.code==200){
    const userList=data.data
    console.log('获取用户列表成功')
    
    console.log(userList)
  }
  else {
    console.log('登录失败')
  }
}

</script>
